package programs.expression.implementedClasses;

import programs.expression.superClasses.Expression;
import programs.expression.superClasses.ExpressionType;
import programs.expression.superClasses.UnaryDoubleExpression;

public class Sqrt extends UnaryDoubleExpression {

	public Sqrt(Expression operand) {
		super(operand);
	}

	@Override
	public Object getValue() {
		return Math.sqrt((Double) getSubExpressionAt(1).getValue());
	}

	@Override
	public boolean isValidExpression() {
		return super.isValidExpression() && (ExpressionType.DOUBLE == getSubExpressionAt(1).getReturnType());
	}

}
